package home2;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

public class home2test {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        ArrayList<Integer>list =new ArrayList<>();
        String s="sd";
        Class<? extends ArrayList> aClass = list.getClass();
        Method[] methods = aClass.getDeclaredMethods();
        for (Method method : methods) {
            System.out.println(method);
        }
        Method add = aClass.getMethod("add", Object.class);
        add.invoke(list, s);
        System.out.println(list);

    }
}
